package com.settlement.system.controller;

import com.settlement.system.common.exception.ServiceException;
import com.settlement.system.reply.ObjectDataResponse;
import com.settlement.system.service.IBaseService;
import com.settlement.system.common.util.common.FasUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import com.settlement.system.model.entity.common.TblOrderSourceInfo;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import com.settlement.system.service.ITblOrderSourceInfoService;

import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 订单来源信息表 前端控制器
 * @author xiaochuang
 * @since 2020-06-17
 */

@Api(tags = "订单来源信息表",description = "订单来源信息表")
@RestController
@RequestMapping("/order/source/info")
public class TblOrderSourceInfoController extends BaseController<TblOrderSourceInfo> {

    @Resource
    private ITblOrderSourceInfoService tblOrderSourceInfoService;

    @Override
    public IBaseService init() {
        return tblOrderSourceInfoService;
    }

    @GetMapping("getSource")
    public ObjectDataResponse getSource(HttpServletRequest request, HttpServletResponse response) throws Exception {
        Map<String,Object> result = new HashMap<>(16);
        try {
            Map<String, Object> params = buildParam(request);
            FasUtil.formatInQueryCondition(params,"parentNo");
            List<TblOrderSourceInfo> rows  = tblOrderSourceInfoService.getAllSource(params);
            result.put("rows",rows);
        } catch (ServiceException e) {
            return new ObjectDataResponse(500,"获取订单来源异常");
        }
        return new ObjectDataResponse<Map>(result,200,"获取订单成功");
    }

}



